import { var_i18n_table,var_i18n_form,var_i18n_getText } from './i18nUtil/i18nUtil.js'
/* 全局mixinJS */
export default {
  data() {
    return {
      // 规则
      'mixin_rules': {},

      // region 国际化方法

      // 表格国际化
      'mixin_i18n_table': var_i18n_table,

      // 表单国际化
      'mixin_i18n_form': var_i18n_form,

      // endregion

      // 预定颜色
      mixin_color: [
        "#409EFF",
        "#1E90FF",
        "#0052D9",
        "#16BAA9",
        "#07C160",
        "#0C819F",
        "#6954F0",
        "#7B40F2",
        '#DAA96E',
        '#ff8c00',
        '#E74C3C',
        '#FF5C93',
        '#9B59B6',
        '#c7158577',
        '#274243',
        '#2B2D30',
        '#555C64',
        '#304156',
      ]
    }
  },

  methods: {
    // 表单验证异常
    mixin_formError(formData,query) {
      if (query.errorText?.length > 0){
        window.$message.error(query.errorText)
        return;
      }
      window.$message.error(var_i18n_getText('errorText.form'))
    },

    toErr(errStr, name) {
      setTimeout(() => {
        window.$message.error(`【${name}】${var_i18n_getText('errorText.components')}：${errStr}`, {
          duration: 3000
        })
      }, 500)
    },

  },

  // 异常捕捉
  errorCaptured(err, instance, info) {
    console.log(err)
    let errStr = err.message
    // 获取组件名称
    const componentName = instance?.$options?.name || ''
    this.toErr(errStr, componentName)
    return false
  }
}